import axios from 'axios'
import {takeEvery, put} from 'redux-saga/effects'
import {get_product_by_id, get_product_by_id_success} from '../actions/productDetail'
import {API} from '../../config'

function* handleDetailProduct (action) {
	let {data} = yield axios.get(`${API}/product/${action.payload.productId}`)
	yield put(get_product_by_id_success(data))
}


export default function* productDetailSaga() {
	yield takeEvery(get_product_by_id, handleDetailProduct)
}